<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // forEach
        let arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
        var sum = 0
        arr.forEach((val, index) => sum += val + index)
        console.log(sum)

        //filter 满足条件返回true
        var newArr = arr.filter((val, index) => val > 50)
        console.log(newArr)

        //map 
        let newArr1 = arr.map((val, index) => val > 50 ? 'good' : 'bad')
        console.log(newArr1)

        //reduce

        let add = arr.reduce((preVal, curVal, curIndex) => preVal + curVal)
        console.log(add)

    </script>
</body>

</html>